import myutil.MyInput;
public class PrimeNumberRange {

	public  int max;
	public  int a[];
	
	public PrimeNumberRange(int m){
		max = m;
		a = new int[m];
		for(int i=0;i<this.max;i++)a[i]=i;
	}
	public  void printPrimeNumbers(){
		int n=2;
		while(true) {
		n=findNext(n);
		System.out.println("Find Next "+n);
		if(n*n >= max) break;
		strikeOut(n);
		}
		for(int i =0 ;i<max;i++){
			if(a[i]!= -1 )System.out.println(a[i]);
		}
	}
	
	public int findNext(int prev){
		
		while(prev <= max){
			if(a[prev++] !=-1) return --prev;
		}
		return 2;
	}
	public void strikeOut(int n){
		int i1=0;
		while(true){
			i1++;
			if (i1*n >=max) break;
			a[i1*n]= -1;
		
		}
		
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		PrimeNumberRange pmr = new PrimeNumberRange(100);
		pmr.printPrimeNumbers();

	}

}
